package com.haierp.service.logistics.impl;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.google.common.collect.Sets;
import com.haierp.exception.ErpCommonException;
import com.haierp.model.ErpOrder;
import com.haierp.model.ShippingOrder;
import com.haierp.model.ShippingTrack;
import com.haierp.model.ShippingTrackPx;
import com.haierp.service.IShippingOrderService;
import com.haierp.service.IShippingTrackService;
import com.haierp.service.logistics.IFadRoadService;
import com.haierp.util.Md5Util;
import com.wangzhixuan.commons.utils.DigestUtils;

@Service("fadRoadService")
public class FadRoadServiceImpl implements IFadRoadService {
	@Autowired
	private IShippingOrderService shippingOrderService;
	@Autowired
	private IShippingTrackService shippingTrackService;

	public static final String MerchantCode = "ruhua1070";
	//public static final String FadRoadUrl = "http://TestService.Fedroad.com/TradingPlatform/TPService1.3.aspx"; 测试地址
	public static final String FadRoadUrl = "http://Service.Fedroad.com/TradingPlatform/TPService1.3.aspx"; //正式地址
	public static final String Token = "df93kofds9af9u";//正式token

	/**
	 * 向指定 URL 发送POST方法的请求
	 * 
	 * @param url
	 *            发送请求的 URL
	 * @param param
	 *            请求参数，请求参数应该是 name1=value1&name2=value2 的形式。
	 * @return 所代表远程资源的响应结果
	 */
	public static String sendPost(String url, String param) {
		PrintWriter out = null;
		BufferedReader in = null;
		String result = "";
		try {
			URL realUrl = new URL(url);
			URLConnection conn = realUrl.openConnection();
			conn.setRequestProperty("accept", "*/*");
			conn.setRequestProperty("connection", "Keep-Alive");
			conn.setRequestProperty("Content-Type", "text/xml");
			conn.setDoOutput(true);
			conn.setDoInput(true);
			out = new PrintWriter(conn.getOutputStream());
			out.print(param);
			out.flush();
			in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			String line;
			while ((line = in.readLine()) != null) {
				result += line;
			}
		} catch (Exception e) {
			//println("发送 POST 请求出现异常！" + e);
			//e.printStackTrace();
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
					in.close();
				}
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}
		return result;
	}

	private static String getPakegeInfo() {
		StringBuilder sb = new StringBuilder();
		sb.append("<Root>");
		sb.append("<Module>Order</Module>");
		sb.append("<DepotId>1</DepotId>");
		sb.append("<Command>ForeOrder</Command>");
		sb.append("<Parameters>");
		sb.append("<OperateDelay></OperateDelay>");
		sb.append("<Forecast>");
		sb.append("<Package><ShippingCo>FedEx Ground</ShippingCo><ShippingNo>pkg123456</ShippingNo>");
		sb.append("<GoodsList>");
		sb.append("<Goods><SKU>test123456</SKU><Count>1</Count></Goods>");
		sb.append("</GoodsList>");
		sb.append("<Service>Photo</Service>");
		sb.append("</Package>");
		sb.append("<Delivery>");
		sb.append("<Package>");
		sb.append("<Address>");
		sb.append("<Recipients>杨晓明</Recipients>");
		sb.append("<Country>中国</Country>");
		sb.append("<Province>浙江省</Province>");
		sb.append("<City>杭州市</City>");
		sb.append("<District>西湖区</District>");
		sb.append("<Address>文一西路</Address>");
		sb.append("<ZipCode>邮编</ZipCode>");
		sb.append("<Mobile>15088735320</Mobile>");
		sb.append("<Email>1534273831@qq.com</Email>");
		sb.append("<IdCard>330104194508223025</IdCard>");
		sb.append("<IdFrontUrl></IdFrontUrl>");
		sb.append("<IdBackUrl></IdBackUrl>");
		sb.append("</Address>");
		sb.append("<ShippingCode></ShippingCode>");
		sb.append("<Service>Remove,Fasten,Change,Tape</Service>");
		sb.append("<Insurance></Insurance>");
		sb.append("</Package>");
		sb.append("</Delivery>");
		sb.append("</Forecast>");
		sb.append("</Parameters>");
		sb.append("</Root>");
		return sb.toString();
	}

	private static String getItemAdd() {
		StringBuilder sb = new StringBuilder();
		sb.append("<Root>");
		sb.append("<Module>SKU</Module>");
		sb.append("<DepotId>2</DepotId>");
		sb.append("<Command>AddSKU</Command>");
		sb.append("<Parameters><SKU>test123456</SKU><UPC>123456</UPC><NameCn>测试商品</NameCn>"
				+ "<NameSp>测试商品</NameSp><NameEn>测试商品</NameEn><NameLc>测试商品</NameLc><Brand>雅诗兰黛</Brand><Specification>50ml"
				+ "</Specification><Ingredient>543543</Ingredient><Origin>美国</Origin>"
				+ "<Currency>CNY</Currency><Price>50</Price>" + "<BuyUrl>商品买狗链接地址</BuyUrl><PicUrl>商品图片链接地址</PicUrl>");
		sb.append("</Parameters></Root>");
		return sb.toString();
	}

	public String changeCharset(String str, String newCharset) throws UnsupportedEncodingException {
		if (str != null) {
			// 用默认字符编码解码字符串。
			byte[] bs = str.getBytes();
			// 用新的字符编码生成字符串
			return new String(bs, newCharset);
		}
		return null;
	}

	@Override
	public void createOrder(Long id) {
		ShippingOrder shippingOrder = shippingOrderService.selectById(id);
		if (shippingOrder == null) {
			throw new ErpCommonException("发货单号异常");
		}
		List<ErpOrder> ErpOrderList = shippingOrderService.queryShippingOrderDetail(shippingOrder.getErpOrderId());
		//预报商品
		try {
			addSku(ErpOrderList);
		} catch (Exception e) {
			return;
		}
		//预报包裹
		try {
			String xmlForber = getPakegeInfo(ErpOrderList, shippingOrder);
			String SignForber = toMD5(xmlForber + Token);
			xmlForber = changeCharset(xmlForber, "UTF-8");
			String strForber = "MerchantCode=" + MerchantCode + "&XmlParams=" + xmlForber + "&Signature="+ SignForber;
			String reponseStringForber = sendPost(FadRoadUrl, strForber);
			//System.out.println("发送 POST 返回！" + reponseStringForber);
			Document doc = DocumentHelper.parseText(reponseStringForber);
			Element userOrder = doc.getRootElement();
			Element orderReturn = userOrder.element("Return");
			String returnOrderValue = orderReturn.getText();
			if (!returnOrderValue.equals("0")) {
				throw new ErpCommonException("联邦此包裹预报异常！"+shippingOrder.getShippingNo());
			}else{
				Element orderParam = userOrder.element("OrderNo");
				String orderNo = orderParam.getText();//联邦订单号
				shippingOrder.setLogisticNo(orderNo);
			}
			shippingOrderService.updateSelectiveById(shippingOrder);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String getItemAdd(List<ErpOrder> ErpOrderList) {
		StringBuilder sb = new StringBuilder();
		sb.append("<Root>");
		sb.append("<Module>SKU</Module>");
		sb.append("<DepotId>2</DepotId>");
		sb.append("<Command>AddSKU</Command>");
		sb.append("<Parameters>");
		for (ErpOrder erpOrder : ErpOrderList) {
			sb.append("<SKU>" + erpOrder.getSkuCode() + "</SKU><UPC>" + erpOrder.getSkuCode() + "</UPC><NameCn>"
					+ erpOrder.getItemName() + "</NameCn>");
			sb.append("<NameSp>" + erpOrder.getItemName() + "</NameSp><NameEn>" + erpOrder.getItemName()
					+ "</NameEn><NameLc>" + erpOrder.getItemName() + "</NameLc><Brand>" + erpOrder.getBrand()
					+ "</Brand><Specification>" + erpOrder.getScale() + erpOrder.getColor() + "</Specification>");
			sb.append("<Ingredient>" + erpOrder.getItemName() + "</Ingredient><Origin>" + erpOrder.getItemName()
					+ "</Origin><Currency>CNY</Currency>" + "<Price>" + erpOrder.getSalePrice()
					+ "</Price><BuyUrl></BuyUrl><PicUrl></PicUrl>");
		}
		sb.append("</Parameters></Root>");
		return sb.toString();
	}
	private static String queryTrackStr(String packageNO) {
		StringBuilder sb = new StringBuilder();
		sb.append("<Root>");
		sb.append("<Module>Order</Module>");
		sb.append("<DepotId>2</DepotId>");
		sb.append("<Command>QueryTrack</Command>");
		sb.append("<Parameters><PackageNo></PackageNo><DeliveryNo>"+packageNO+"</DeliveryNo>");
		sb.append("</Parameters></Root>");		
		return sb.toString();
	}

	private static String getPakegeInfo(List<ErpOrder> ErpOrderList, ShippingOrder shippingOrder) {
		StringBuilder sb = new StringBuilder();
		sb.append("<Root>");
		sb.append("<Module>Order</Module>");
		sb.append("<DepotId>2</DepotId>");
		sb.append("<Command>ForeOrder</Command>");
		sb.append("<Parameters>");
		sb.append("<OperateDelay></OperateDelay>");
		sb.append("<Forecast>");
		sb.append("<Package><ShippingCo>FedEx Ground</ShippingCo><ShippingNo>" + shippingOrder.getShippingNo()
				+ "</ShippingNo>");
		sb.append("<GoodsList>");// 入仓信息
		for (ErpOrder erpOrder : ErpOrderList) {
			sb.append("<Goods><SKU>" + erpOrder.getSkuCode() + "</SKU><Count>" + erpOrder.getQuantity()
					+ "</Count></Goods>");
		}
		sb.append("</GoodsList>");
		//sb.append("<Service>Photo</Service>");
		sb.append("</Package>");
		sb.append("</Forecast>");
		sb.append("<Delivery>");
		sb.append("<Package>");
		sb.append("<Address>");
		sb.append("<Recipients>" + shippingOrder.getReceiver() + "</Recipients>");
		sb.append("<Country>CN</Country>");
		sb.append("<Province>" + shippingOrder.getReceiverState() + "</Province>");
		sb.append("<City>" + shippingOrder.getReceiverCity() + "</City>");
		sb.append("<District>" + shippingOrder.getReceiverDistrict() + "</District>");
		sb.append("<Address>" + shippingOrder.getAddressDetail() + "</Address>");
		sb.append("<ZipCode></ZipCode>");
		sb.append("<Mobile>" + shippingOrder.getTelephone() + "</Mobile>");
		sb.append("<Email></Email>");
		sb.append("<IdCard>" + shippingOrder.getIdCard() + "</IdCard>");
		sb.append("<IdFrontUrl></IdFrontUrl>");
		sb.append("<IdBackUrl></IdBackUrl>");
		sb.append("</Address>");
		sb.append("<GoodsList>");// 出仓信息
		for (ErpOrder erpOrder : ErpOrderList) {
			sb.append("<Goods><SKU>" + erpOrder.getSkuCode() + "</SKU><Count>" + erpOrder.getQuantity()
					+ "</Count></Goods>");
		}
		sb.append("</GoodsList>");
		//sb.append("<ShippingCode>US_Postal</ShippingCode>");//测试地址的线路
		sb.append("<ShippingCode>UPU-HKETK</ShippingCode>");//正式邮盟线路地址
		//sb.append("<Service>Fasten</Service>");
		sb.append("<Insurance></Insurance>");
		sb.append("</Package>");
		sb.append("</Delivery>");
		sb.append("</Parameters>");
		sb.append("</Root>");
		return sb.toString();
	}

	@Override
	public void shippingTrack(String shipperOrderNo) throws ParseException {
		String xmlTracking = queryTrackStr(shipperOrderNo);
		String Signature = toMD5(xmlTracking + Token);
		//String Signature = Md5Util.getMD5("<Root><Module>Order</Module><DepotId>2</DepotId><Command>QueryTrack</Command><Parameters><PackageNo>P00200335962</PackageNo><DeliveryNo></DeliveryNo></Parameters></Root>df93kofds9af9u");
		try {
			xmlTracking = changeCharset(xmlTracking, "UTF-8");
			String strData = "MerchantCode=" + MerchantCode + "&XmlParams=" + xmlTracking + "&Signature=" + Signature;
			String reponseShippingTrack = sendPost(FadRoadUrl, strData);
			//System.out.println("发送 POST 返回！" + reponseShippingTrack);
			Document doc;
			try {
				doc = DocumentHelper.parseText(reponseShippingTrack);
				Element user = doc.getRootElement();
				Element payReturn = user.element("Return");
				String returnValue = payReturn.getText();
				if (!returnValue.equals("0")) {
					throw new ErpCommonException("包裹物流轨迹抓取异常！");
				}
				SimpleDateFormat date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
				Iterator iter = user.elementIterator("TrackList");
				ShippingTrack shippingTrack = new ShippingTrack();
				shippingTrack.setShippingNo(shipperOrderNo);
				shippingTrack.setLogisticNo(shipperOrderNo);
				EntityWrapper<ShippingTrack> selEntityWrapper = new EntityWrapper<ShippingTrack>();
				selEntityWrapper.where("shipping_no={0}", shipperOrderNo);
				List<ShippingTrack> shippingReadyTracks = shippingTrackService.selectList(selEntityWrapper);
				Set<Integer>  statusSet = Sets.newHashSet();
				if(shippingReadyTracks.size()>0){
					shippingReadyTracks.forEach(item -> {
						statusSet.add(item.getStatus());
					});
				}
				String con = "";
				StringBuilder sb = new StringBuilder();
				while (iter.hasNext()) {
					Element recordEle = (Element) iter.next();
					Iterator iters = recordEle.elementIterator("Track");
					while (iters.hasNext()) {
						Element itemEle = (Element) iters.next();
						String trackTime = itemEle.elementTextTrim("TrackTime");
						String templetId = itemEle.elementTextTrim("TempletId");
						String message = itemEle.elementTextTrim("Message");
						if (!statusSet.contains(0) && templetId.substring(0, 1).equals("2")) {
							shippingTrack.setStatus(0);
							statusSet.add(0);
							shippingTrack.setInfo("未出库");
							shippingTrack.setGmtCreate(date.parse(trackTime));
							shippingTrack.setGmtModify(date.parse(trackTime));
							shippingTrackService.insertSelective(shippingTrack);
						}
						else if(!statusSet.contains(1) && templetId.substring(0, 1).equals("3")){
							shippingTrack.setStatus(1);
							statusSet.add(1);
							shippingTrack.setOverseaInTime(date.parse(trackTime));
							shippingTrack.setInfo("发往国内");
							shippingTrack.setGmtCreate(date.parse(trackTime));
							shippingTrack.setGmtModify(date.parse(trackTime));
							shippingTrackService.insertSelective(shippingTrack);
						}else if (!statusSet.contains(3) && templetId.substring(0, 1).equals("4")) {
							shippingTrack.setStatus(3);
							statusSet.add(3);
							shippingTrack.setOverseaInTime(date.parse(trackTime));
							shippingTrack.setInfo("抵达国内");
							shippingTrack.setGmtCreate(date.parse(trackTime));
							shippingTrack.setGmtModify(date.parse(trackTime));
							shippingTrackService.insertSelective(shippingTrack);
						}else if(!statusSet.contains(4)&& templetId.equals("5001") || templetId.equals("5002")){
							shippingTrack.setStatus(4);
							statusSet.add(4);
							shippingTrack.setOverseaInTime(date.parse(trackTime));
							shippingTrack.setInfo(message);
							shippingTrack.setGmtCreate(date.parse(trackTime));
							shippingTrack.setGmtModify(date.parse(trackTime));
							shippingTrackService.insertSelective(shippingTrack);
						}else if (!statusSet.contains(5) && templetId.equals("5202")) {
							shippingTrack.setStatus(5);
							shippingOrderService.updateStatusByShippingNo(shipperOrderNo);
							shippingTrack.setBuyerSignTime(date.parse(trackTime));
							shippingTrack.setInfo("用户已签收");
							shippingTrack.setGmtCreate(date.parse(trackTime));
							shippingTrack.setGmtModify(date.parse(trackTime));
							shippingTrackService.insertSelective(shippingTrack);
						}
					}
				}
			} catch (DocumentException e) {
				e.printStackTrace();
			}

		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	private String toMD5(String plainText) {
		String str = "";
		try {
			// 生成实现指定摘要算法的 MessageDigest 对象。
			MessageDigest md = MessageDigest.getInstance("MD5");
			// 使用指定的字节数组更新摘要。
			md.update(plainText.getBytes());
			// 通过执行诸如填充之类的最终操作完成哈希计算。
			byte b[] = md.digest();
			// 生成具体的md5密码到buf数组
			int i;
			StringBuffer buf = new StringBuffer("");
			for (int offset = 0; offset < b.length; offset++) {
				i = b[offset];
				if (i < 0)
					i += 256;
				if (i < 16)
					buf.append("0");
				buf.append(Integer.toHexString(i));
			}
			str = buf.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return str;

	}

	/**
	 * 预报商品
	 */
	public void addSku(List<ErpOrder> ErpOrderList) throws Exception {
		List<ErpOrder> erpListNoDupAndSort = removeDuplicateErp(ErpOrderList);
		for(ErpOrder erpOrder : erpListNoDupAndSort) {
			StringBuilder sb = new StringBuilder();
			sb.append("<Root>");
			sb.append("<Module>SKU</Module>");
			sb.append("<DepotId>2</DepotId>");
			sb.append("<Command>AddSKU</Command>");
			sb.append("<Parameters>");
			sb.append("<SKU>" + erpOrder.getSkuCode() + "</SKU><UPC></UPC><NameCn>"
					+ clearNotChinese(erpOrder.getItemName()) + "</NameCn>");
			sb.append("<NameSp>" + clearNotChinese(erpOrder.getItemName()) + "</NameSp><NameEn>" + clearNotChinese(erpOrder.getItemName())
					+ "</NameEn><NameLc>" + clearNotChinese(erpOrder.getItemName()) + "</NameLc><Brand>" + clearNotChinese(erpOrder.getBrand())
					+ "</Brand><Specification>" + erpOrder.getScale() + erpOrder.getColor() + "</Specification>");
			sb.append("<Ingredient>" + clearNotChinese(erpOrder.getItemName()) + "</Ingredient><Origin>" + clearNotChinese(erpOrder.getItemName())
					+ "</Origin><Currency>CNY</Currency>" + "<Price>" + erpOrder.getSalePrice()
					+ "</Price><BuyUrl></BuyUrl><PicUrl></PicUrl>");
			sb.append("</Parameters></Root>");

			String xmlItemadd = sb.toString();
			String Signature = toMD5(xmlItemadd + Token);

			xmlItemadd = changeCharset(xmlItemadd, "UTF-8");
			String strData = "MerchantCode=" + MerchantCode + "&XmlParams=" + xmlItemadd + "&Signature=" + Signature;
			//System.out.println("发送 post 内容！" + strData);
			String reponseStringAdd = sendPost(FadRoadUrl, strData);
			//System.out.println("发送 POST 返回！" + reponseStringAdd);

			Document doc = DocumentHelper.parseText(reponseStringAdd);
			Element user = doc.getRootElement();
			Element payReturn = user.element("Return");
			String returnValue = payReturn.getText();
			if (!returnValue.equals("0")) {
				throw new ErpCommonException("商品预报异常！");
			}
		}
	}
	
	 private String clearNotChinese(String buff){
	     	String tmpString =buff.replaceAll("(?i)[^a-zA-Z0-9\u4E00-\u9FA5]", "");//去掉所有中英文符号
	    	char[] carr = tmpString.toCharArray();
	    	for(int i = 0; i<tmpString.length();i++){
	    		if(carr[i] < 0xFF){
	    			carr[i] = ' ' ;//过滤掉非汉字内容
	    		}
	    	}
	    	return String.copyValueOf(carr).trim();
	    }
	 
	    private static ArrayList<ErpOrder> removeDuplicateErp(List<ErpOrder> erpOrder) {
	        Set<ErpOrder> set = new TreeSet<ErpOrder>(new Comparator<ErpOrder>() {
	            @Override
	            public int compare(ErpOrder o1, ErpOrder o2) {
	                //按照sku 去重
	                return o1.getSkuCode().compareTo(o2.getSkuCode());
	            }
	        });
	        set.addAll(erpOrder);
	        return new ArrayList<ErpOrder>(set);
	    }
	    
	    public static File saveUrlAs(String url,String filePath,String method){  
	        //System.out.println("fileName---->"+filePath);  
	        //创建不同的文件夹目录  
	        File file=new File(filePath);  
	        //判断文件夹是否存在  
	        if (!file.exists())  
	       {  
	           //如果文件夹不存在，则创建新的的文件夹  
	            file.mkdirs();  
	       }  
	        FileOutputStream fileOut = null;  
	        HttpURLConnection conn = null;  
	        InputStream inputStream = null;  
	        try  
	       {  
	            // 建立链接  
	            URL httpUrl=new URL(url);  
	            conn=(HttpURLConnection) httpUrl.openConnection();  
	            //以Post方式提交表单，默认get方式  
	            conn.setRequestMethod(method);  
	            conn.setDoInput(true);    
	            conn.setDoOutput(true);  
	            // post方式不能使用缓存   
	            conn.setUseCaches(false);  
	            //连接指定的资源   
	            conn.connect();  
	            //获取网络输入流  
	            inputStream=conn.getInputStream();  
	            BufferedInputStream bis = new BufferedInputStream(inputStream);  
	            //判断文件的保存路径后面是否以/结尾  
	            if (!filePath.endsWith("/")) {  
	     
	                filePath += "/";  
	     
	                }  
	            //写入到文件（注意文件保存路径的后面一定要加上文件的名称）  
	            fileOut = new FileOutputStream(filePath+"123.png");  
	            BufferedOutputStream bos = new BufferedOutputStream(fileOut);  
	              
	            byte[] buf = new byte[4096];  
	            int length = bis.read(buf);  
	            //保存文件  
	            while(length != -1)  
	            {  
	                bos.write(buf, 0, length);  
	                length = bis.read(buf);  
	            }  
	            bos.close();  
	            bis.close();  
	            conn.disconnect();  
	       } catch (Exception e)  
	       {  
	            e.printStackTrace();  
	            System.out.println("抛出异常！！");  
	       }  
	          
	        return file;  
	    }  
	    
	    public static void main(String[] args)  {  
	        String photoUrl = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";                                      
	        String fileName = photoUrl.substring(photoUrl.lastIndexOf("/"));   
	        //System.out.println("fileName---->"+fileName);  
	        String filePath = "d:";    
	        File file = saveUrlAs(photoUrl, filePath + fileName,"GET");    
	        System.out.println("Run ok!/n<BR>Get URL file " + file);    
	    	/*String xmlTracking = queryTrackStr("PKG18030515141456554");
			String Signature = toMD5(xmlTracking + Token);
			//String Signature = Md5Util.getMD5("<Root><Module>Order</Module><DepotId>2</DepotId><Command>QueryTrack</Command><Parameters><PackageNo>P00200335962</PackageNo><DeliveryNo></DeliveryNo></Parameters></Root>df93kofds9af9u");
				try {
					xmlTracking = changeCharset(xmlTracking, "UTF-8");
					String strData = "MerchantCode=" + MerchantCode + "&XmlParams=" + xmlTracking + "&Signature=" + Signature;
					String reponseShippingTrack = sendPost(FadRoadUrl, strData);
					System.out.println("发送 POST 返回！" + reponseShippingTrack);
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}*/
	    }

}
